import matplotlib.pyplot as plt

f = open("out.txt", "r")
lines = f.readlines()
# X1_True, X2_True,X1_MEA, X2_MEA, X1_Prior_Hat, X2_Prior_Hat,X1_Hat, X2_Hat = [],[],[],[],[],[],[],[]
ZX, ZXV, ZY, ZYV, HatX, HatXV, HatY, HatYV = [], [], [], [], [], [], [], []

tmp = lines[0].split(',')
for i in tmp[:-1]:
    if i == ' ':
        break
    ZX.append(float(i))

tmp = lines[1].split(',')
for i in tmp[:-1]:
    ZXV.append(float(i))

tmp = lines[2].split(',')
for i in tmp[:-1]:
    if len(i) == 0:
        break
    ZY.append(float(i))

tmp = lines[3].split(',')
for i in tmp[:-1]:
    if len(i) == 0:
        break
    ZYV.append(float(i))

tmp = lines[4].split(',')
for i in tmp[:-1]:
    if len(i) == 0:
        break
    HatX.append(float(i))

tmp = lines[5].split(',')
for i in tmp[:-1]:
    if len(i) == 0:
        break
    HatXV.append(float(i))

tmp = lines[6].split(',')
for i in tmp[:-1]:
    if len(i) == 0:
        break
    HatY.append(float(i))

tmp = lines[7].split(',')
for i in tmp[:-1]:
    if len(i) == 0:
        break
    HatYV.append(float(i))

fig, axs = plt.subplots(1, 2)
axs[0].plot(ZX, "-", label="Mea", linewidth=1)  # Plot some data on the axes.
axs[0].plot(HatX, "-", label="Hat", linewidth=1)  # Plot some data on the axes.
axs[0].set_title("X position")
axs[0].set_xlabel('Delta T')  # Add an x-label to the axes.
axs[0].legend()  # Add a legend.

#axs[1].plot(ZXV, "-", label="Mea", linewidth=1)  # Plot some data on the axes.
#axs[1].plot(HatXV, "-", label="Hat", linewidth=1)  # Plot some data on the axes.
#axs[1].set_title("X velocity")
#axs[1].set_xlabel('Delta T')  # Add an x-label to the axes.
#axs[1].legend()  # Add a legend.

axs[1].plot(ZY, "-", label="Mea", linewidth=1)  # Plot some data on the axes.
axs[1].plot(HatY, "-", label="Hat", linewidth=1)  # Plot some data on the axes.
axs[1].set_title("Y position")
axs[1].set_xlabel('Delta T')  # Add an x-label to the axes.
axs[1].legend()  # Add a legend.

#axs[3].plot(ZYV, "-", label="Mea", linewidth=1)  # Plot some data on the axes.
#axs[3].plot(HatYV, "-", label="Hat", linewidth=1)  # Plot some data on the axes.
#axs[3].set_title("Y velocity")
#axs[3].set_xlabel('Delta T')  # Add an x-label to the axes.
#axs[3].legend()  # Add a legend.

plt.show()